import re
import sys
import urllib2

if sys.argv > 2:
    i = 0
    listRegexp = ['[0]\d\d\d\d\d\d\d\d\d']
    listRegexp.append('[0]\d \d\d \d\d \d\d \d\d')
    listRegexp.append('[0]\d.\d\d.\d\d.\d\d.\d\d')
    listRegexp.append('\\+33 6 \d\d \d\d \d\d \d\d')
    if sys.argv[1] == "-file":
        for arg in sys.argv:
    
            if i<2:
                i=i+1
            else:
                f = open(arg,"r")
                html = f.read()
                listNum = list()
                for regexpString in listRegexp:
                    regexp = re.compile(regexpString)
                    listNum = regexp.findall(html) + listNum
                print listNum

    if sys.argv[1] == "-url":
        for arg in sys.argv:
            if i<2:
                i=i+1
            else:
                response = urllib2.urlopen(arg)
                html = response.read()
                listNum = list()
                for regexpString in listRegexp:
                    regexp = re.compile(regexpString)
                    listNum = regexp.findall(html) + listNum
                print listNum
    if sys.argv[1] == "-urlfile":
        f = open(sys.argv[2],"r")
        lines = f.readlines()
        html = ''
        for line in lines:
            try:
                response = urllib2.urlopen(line)
                html = response.read()
            except ValueError:
                print "error"
            listNum = list()
            for regexpString in listRegexp:
                regexp = re.compile(regexpString)
                listNum = regexp.findall(html) + listNum
            print listNum
